<template>
  <slot name="header"></slot>
</template>
<script>
import { getCurrentInstance, onMounted } from 'vue';

//<slot v-if="$slots.default" /> 无命名槽，且检查默认槽是否为空
//useSlots().default()?.[0]?.children?.length>0   $slots.default为函数,总是为真时
export default {
  setup() {
    const instance = getCurrentInstance();

    onMounted(() => {
      if (instance.slots.header) {
        console.log('Header slot is present');
      } else {
        console.log('Header slot is not present')
      }
    })
  }
}
</script>